package com.junmoo.www.tool;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;


@Accessors(chain = true)
@ToString
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private int code;
    private String msg;
    private Object data;

    public static Result setResult(int code,  String msg, Object data){
        return new Result().setCode(code).setMsg(msg).setData(data);
    }

    public static Result success(){
        return setResult(200,"success",null);
    }

    public static Result success(Object data){
        return setResult(200,"success",data);
    }

    public static Result success(String msg){
        return setResult(200,msg,null);
    }

    public static Result success(String msg, Object data){
        return setResult(200,msg,data);
    }

    public static Result error(){
        return setResult(500,"error",null);
    }

    public static Result error(Object error){
        return setResult(500,"error",error);
    }

    public static Result error(String msg){
        return setResult(500,msg,null);
    }

    public static Result error(String msg, Object error){
        return setResult(500,msg,error);
    }

}
